﻿@using Telerik.Web.Mvc.UI
@model IEnumerable<idoshop.Models.ProductCategory>
@{
    ViewBag.Title = "Index";
    Layout = "~/Areas/admin/Views/Shared/_Layout.cshtml";
}
<div class="row-fluid">
    <h3 class="header smaller lighter blue">
        Loại sản phẩm</h3>
    <div class="pbBody">
        <!-- Grid's here -->
        @(Html.Telerik().Grid(Model)
              .Name("grdProductCategory")
              .DataKeys(keys => keys.Add(o => o.id))
              .DataBinding(databinding => databinding.Server()
                  .Update("edit", "productcategories").Select("index", "productcategories").Delete("delete", "productcategories")
                  )
              .ToolBar(commands => commands
                                       .Custom()
                                       .HtmlAttributes(new { id = "create" })
                                       .Text("Add new category")
                                       .ButtonType(GridButtonType.ImageAndText)
                                       .ImageHtmlAttributes(new { @class = "t-icon t-add" })
                                       .Action("Create", "ProductCategories"))
                                       .Selectable()
            .Reorderable(r => r.Columns(true))
            .Resizable(r => r.Columns(true))
              .Columns(columns => {
                               columns.Bound(o => o.name).Title("Tên").Width(100);
                               columns.Bound(o => o.name_en).Title("Tên tiếng Anh").Width(100);
                               columns.Bound(o => o.order_no).Title("Thứ tự").Width(30);
                               columns.Bound(o => o.is_active).Title("Active").Width(20)
                                   .Template(@<text>
                                                @if (item.is_active) {
                                                    <span class="label label-success arrowed">On</span>
                                                } else {
                                                    <span class="label label-important arrowed-in">Off</span>
                                                }
                                            </text>);
                                      columns.Command(cmd => {

                                          cmd.Custom("edit").ButtonType(GridButtonType.ImageAndText)
                                              .ImageHtmlAttributes(new { @class = "t-icon t-edit" })
                                              .Action("edit", "ProductCategories")
                                              .Text("Edit").ButtonType(GridButtonType.ImageAndText);
                                          cmd.Delete().ButtonType(GridButtonType.ImageAndText);
                                      }).Width(35).HtmlAttributes(new { style = "text-align: right" });
              })
              .Groupable()
              .Sortable()
              .Pageable()
              .Filterable())
        <!-- end of grid -->
    </div>
    <div class="pbFooter secondaryPalette">
        <div class="bg">
        </div>
    </div>
</div>
